package com.climber.spb_rabbitmq.spb_backqueue.service;

import com.climber.spb_rabbitmq.spb_backqueue.config.RabbitMQConfig;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class MessageReceiver {

    @RabbitListener(queues = RabbitMQConfig.CONFIRM_QUEUE_NAME)
    public void receiveMsg(Message message){
        String msg=new String(message.getBody());
        System.out.printf("接受到队列 confirm.queue 消息:%s\n",msg);
    }

    @RabbitListener(queues = RabbitMQConfig.BACK_QUEUE)
    public void receiveBackMsg(Message message){
        String msg=new String(message.getBody());
        System.out.printf("接受到备份队列 back.queue 消息:%s\n",msg);
    }

    @RabbitListener(queues = RabbitMQConfig.WARN_QUEUE)
    public void receiveWarnMsg(Message message){
        String msg=new String(message.getBody());
        System.out.printf("接受到警告队列 warn.queue 消息:%s\n",msg);
    }


}
